import React, { FC, useRef } from 'react';
import Login from '../../../components/login';
import { httpJson } from "../../../services/http";
import { useHistory } from 'react-router-dom';
import { set } from '../../../utils/storage';

// 用户登录页
const UserLogin: FC = props => {
    const userRef = useRef<any>();
    const history = useHistory();

    const login = () => {
        console.log("可以拿到用户登录信息", userRef.current.getFieldsValue())
        httpJson('POST', '/api/user/login', userRef.current.getFieldsValue())
            .then((res: any) => {
                console.log("用户登录成功返回信息", res);
                if (res.data.code == '200') {
                    history.push("/user");
                    // 存用户数据到localStorage里面
                }
            })
            .catch(err => {
                console.log(err)
            })
    }
    return <Login login={login} valueLink="" agreement="《云食用户隐私政策》" ref={userRef} />
}
export default UserLogin;
